package leetcode_day._2022._202203._0110;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yzh
 * @version 1.0
 * @date 2022/3/6 22:36
 * 适合打劫银行的日子
 * 算法：动态规划 + 前缀和
 */
public class _06_2100 {

    public List<Integer> goodDaysToRobBank(int[] security, int time) {
        List<Integer> ans = new ArrayList<>();
        int len = security.length;
        int[] dp1 = new int[len];
        for (int i = 1; i < len; i++) if (security[i - 1] >= security[i]) dp1[i] = dp1[i - 1] + 1;
        int[] dp2 = new int[len];
        for (int i = len - 2; i >= 0; i--) if (security[i] <= security[i + 1]) dp2[i] = dp2[i + 1] + 1;
        for (int i = time; i < len - time; i++) if (dp1[i] - time >= 0 && dp2[i] - time >= 0) ans.add(i);
        return ans;
    }

}
